package controllers

import (
	"github.com/astaxie/beego"
	"fmt"
"wcy-xmt-api/models"
)

// 搜索
type SearchController struct {
	beego.Controller
}

// @Title search
// @Description 搜索
// @Param app form int true "App编号"
// @Param query form string true "需要查询关键词"
// @Param size form int false "请求条目数"
// @Param current_page form int false "当前Page，在分页时候需要使用"
// @Param search_type form int false "搜索类型1订阅，2文章，3视频，4直播，在分页时候需要使用"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.RecommendInfo
// @router / [post]
func (this *SearchController) Search() {
	fmt.Println("run SearchController Search")
	resStatus := &models.ResStatus{}
	searchInfo := &models.SearchInfo{}

	subInfo := &models.SubscribeInfo{}
	subInfo.CurPage = 1
	subInfo.Total = 10

	subs := []*models.Subscribe{}
	sub := &models.Subscribe{}
	sub.IconUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	sub.Id = 1
	sub.IsSubscribe = 1
	sub.Title = "36氪"
	sub.SubscribeNum = 8
	subs = append(subs,sub)
	sub = &models.Subscribe{}
	sub.IconUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	sub.Id = 2
	sub.IsSubscribe = 0
	sub.Title = "36氪"
	sub.SubscribeNum = 12
	subs = append(subs,sub)
	subInfo.Data = subs
	searchInfo.SubscribeInfo = subInfo


	articleInfo := &models.ArticleInfo{}
	articleInfo.CurPage = 1
	articleInfo.Total = 10

	arts := []*models.Article{}
	art := &models.Article{}
	art.ArticleCategory = "发现"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5NTAyODc2MA==&mid=405480469&idx=5&sn=1896d722e67686b306b9a427e7605952&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	art.Id = 1
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "02月17日"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	art.GzhId = "sds121"
	art.GzhName = "宁波发布"
	art.IsCollect = 1
	art.IsPraise = 0
	arts = append(arts,art)
	art = &models.Article{}
	art.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	art.Time = "1小时前"
	art.Title = "爱你就是把你的朋友圈从头看到尾。"
	art.Id = 2
	art.ArticleCategory = "文化"
	art.ContentUrl = "http://mp.weixin.qq.com/s?__biz=MjM5Njc4MDIzNw==&mid=403816102&idx=1&sn=5de33be5dd43fa6d9d8f19b751d859a2&3rd=MzA3MDU4NTYzMw==&scene=6#rd"
	arts = append(arts,art)
	articleInfo.Data = arts
	searchInfo.ArticleInfo = articleInfo


	videoInfo := &models.VideoInfo{}
	videoInfo.CurPage = 1
	videoInfo.Total = 10

	videos := []*models.Video{}
	vio := &models.Video{}
	vio.Id = 1
	vio.ActiveNum = 1221
	vio.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	vio.IsLive = 1
	vio.Title = "两岸青山楼外楼"

	videos = append(videos,vio)
	vio = &models.Video{}
	vio.Id = 2
	vio.ActiveNum = 12223
	vio.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	vio.IsLive = 0
	vio.Title = "两岸青山楼外楼"

	videos = append(videos,vio)
	videoInfo.Data = videos
	searchInfo.VideoInfo = videoInfo


	imgTxtInfo := &models.ImgTxtInfo{}
	imgTxtInfo.CurPage = 1
	imgTxtInfo.Total = 10

	imgTxts := []*models.ImgTxt{}
	imgTxt := &models.ImgTxt{}
	imgTxt.Id = 1
	imgTxt.ActiveNum = 2323
	imgTxt.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	imgTxt.IsLive = 1
	imgTxt.Title = "小米5发布会"

	imgTxts = append(imgTxts,imgTxt)
	imgTxt = &models.ImgTxt{}
	imgTxt.Id = 2
	imgTxt.IsLive = 0
	imgTxt.ImageUrl = "http://img4.3lian.com/sucai/img6/230/29.jpg"
	imgTxt.ActiveNum = 23223
	imgTxt.Title = "小米5发布会"

	imgTxts = append(imgTxts,imgTxt)
	imgTxtInfo.Data = imgTxts
	searchInfo.ImgTxtInfo = imgTxtInfo


	searchInfo.Message = ""
	searchInfo.Code = 0
	resStatus.Code = 200
	resStatus.Data = searchInfo
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}